﻿using System;
using System.IO;

namespace Program12
{
    class Program
    {
        //Directory文件夹的处理
        static void Main(string[] args)
        {
            Directory.CreateDirectory(@"c:\AAA");
            //Console.WriteLine("创建成功");

            //文件删除
            //try
            //{
            //    Directory.Delete(@"c:\AAA");
            //    Console.WriteLine("删除成功");
            //}
            //catch
            //{
            //    Console.WriteLine("文件夹不存在");
            //}

            //文件移动
            //Directory.Move(@"c:\AppData\AAA", @"c:\AAA");
            //Console.WriteLine("文件夹移动成功");
            //查询文件夹




            //判断每个文件夹是否存在
            if (Seek(@"c:\AAA"))
            {
                Console.WriteLine("文件夹存在");
            }
            else
            {
                Console.WriteLine("文件夹不存在");
            }

            bool Seek(string pathway)
            {
                return Directory.Exists(pathway);
            }//列出文件夹
            string keyPath = "100";
            string[] path = Directory.GetDirectories(@"c:\AAA");
            foreach (var p in path)
            {
                if (p.Contains(keyPath))
                {
                    Console.WriteLine(p);
                    break;
                }
            }

            string[] paths = Directory.GetFiles(@"c:\AAA");

            for(var i=0;i<paths.Length;i++)
            {
                    Console.WriteLine(paths[i]);
            }

        }
            
    }
}
